IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_MachineMSInstalledComponents_Machine]') AND parent_object_id = OBJECT_ID(N'[dbo].[MachineMSInstalledComponents]'))
BEGIN
     ALTER TABLE [dbo].[MachineMSInstalledComponents] DROP CONSTRAINT [FK_MachineMSInstalledComponents_Machine]
END
GO

ALTER TABLE [dbo].[MachineMSInstalledComponents] WITH CHECK ADD CONSTRAINT [FK_MachineMSInstalledComponents_Machine] 
     FOREIGN KEY([MachineId]) REFERENCES [dbo].[Machine] ([MachineId])
GO
